package $___666;

import java.util.Scanner;

public class Turn10into2 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入字符串：");
        String str = sc.nextLine(); 
        System.out.println("二进制结果为；");
        for(int i = 0; i < str.length(); i++) {
            String strTwo = "";
            //将切割得到的每个字符转换成ASCII码，也可用byte[] b = str.getBytes();
            int ascii = str.charAt(i);
            //将到的ASCII码转换成对应的二进制数
            for(int j = 0; j < 8; j++) {
                //十进制转二进制，十进制数除以2取余数
                int two = ascii % 2;
                ascii = ascii / 2;
                //将这些余数依次拼接成字符串
                strTwo = strTwo + two;
            }//得到的字符串序列需要反转才能得到正确的二进制数
            StringBuffer bStrTwo = new StringBuffer(strTwo);
            StringBuffer revStrTwo = bStrTwo.reverse();
            System.out.print(revStrTwo + " ");
        }
    }
}
